<template>
  <div class="stores">
    <a-page-header
      title="门店管理"
      sub-title="门店信息管理"
    >
      <template #extra>
        <a-button type="primary">
          <PlusOutlined />
          新增门店
        </a-button>
      </template>
    </a-page-header>

    <a-card>
      <a-table
        :columns="columns"
        :data-source="stores"
        :pagination="pagination"
      >
        <template #bodyCell="{ column, record }">
          <template v-if="column.key === 'status'">
            <a-tag :color="record.status === 1 ? 'green' : 'red'">
              {{ record.status === 1 ? '营业中' : '已关闭' }}
            </a-tag>
          </template>
          <template v-else-if="column.key === 'action'">
            <a-space>
              <a-button type="link" size="small">编辑</a-button>
              <a-button type="link" size="small">查看</a-button>
              <a-button type="link" size="small" danger>删除</a-button>
            </a-space>
          </template>
        </template>
      </a-table>
    </a-card>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive } from 'vue'
import { PlusOutlined } from '@ant-design/icons-vue'

const columns = [
  { title: '门店名称', dataIndex: 'name', key: 'name' },
  { title: '门店编码', dataIndex: 'code', key: 'code' },
  { title: '地址', dataIndex: 'address', key: 'address' },
  { title: '联系电话', dataIndex: 'phone', key: 'phone' },
  { title: '店长', dataIndex: 'manager', key: 'manager' },
  { title: '状态', dataIndex: 'status', key: 'status' },
  { title: '操作', key: 'action', width: 200 },
]

const stores = ref([
  {
    id: 1,
    name: '中山路店',
    code: 'STORE001',
    address: '广东省广州市越秀区中山路123号',
    phone: '020-8888-0001',
    manager: '王店长',
    status: 1
  },
  {
    id: 2,
    name: '天河城店',
    code: 'STORE002',
    address: '广东省广州市天河区天河路456号',
    phone: '020-8888-0002',
    manager: '李店长',
    status: 1
  }
])

const pagination = reactive({
  current: 1,
  pageSize: 10,
  total: 2,
})
</script>

<style scoped>
.stores {
  padding: 24px;
}
</style>